package conf

import (
	"bytes"
	"github.com/BurntSushi/toml"
	_ "github.com/go-sql-driver/mysql"
	"io/ioutil"
	"os"
)

type Api_toml struct{}

func (*Api_toml) Read(fpath string, v interface{}) {
	if _, err := toml.DecodeFile(fpath, v); err != nil {
		return
	}
	return
}
func (*Api_toml) Write(fpath string, v interface{}) {
	buf := new(bytes.Buffer)
	if err := toml.NewEncoder(buf).Encode(v); err != nil {
		return
	}
	if err := ioutil.WriteFile(fpath, buf.Bytes(), os.ModeType); err != nil {
		return
	}
	return
}
